package com.aggron.concurrency.threadpool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author LR2SD
 * @description SingleThreadExecutor测试类
 * @date 2018-06-14 21:26
 */
@Slf4j
public class ThreadPoolExample3 {
    public static void main(String [] args){
        ExecutorService executorService= Executors.newSingleThreadExecutor();
        for (int i = 0; i < 10; i++) {
            final int index=i;
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    log.info("{}",index);
                }
            });
        }
        executorService.shutdown();
    }
}
